<?php

namespace app\api\controller;

use app\api\validate\UserValidate;
use app\api\service\UserService;

class User extends Base
{
    protected $middleware = ['NotFoundMiddleware'];

    /**
     * 用户登录
     * @needLogin FALSE
     * @method POST
     * @return void
     */
    public function authLogin()
    {
        if (($msg = UserValidate::authLogin($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = UserService::authLogin($this->params);
        apiReturn($code, $msg, $data);
    }

    /**
     * 用户登录2
     * @needLogin FALSE
     * @method POST
     * @return void
     */
    public function accountLogin()
    {
        if (($msg = UserValidate::accountLogin($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = UserService::accountLogin($this->params);
        apiReturn($code, $msg, $data);
    }

    /**
     * 编辑基本资料
     * @needLogin TRUE
     * @method POST
     * @return void
     */
    public function updateBaseInfo()
    {
//        if (($msg = UserValidate::updateBaseInfo($this->params)) !== true) apiReturn(201, $msg);
        $this->checkRepeat('User/updateBaseInfo', $this->_user_info['id']);
        list($code, $msg, $data) = UserService::updateBaseInfo($this->_user_info, $this->params);
        apiReturn($code, $msg, $data);
    }
}